<?php
/**
 * Generic recording and displaying of text  
 * 
 * @author Magnus Stoveland <mstoveland@gmail.com>
 * 
 */

class Info
{
    function add($string, $key = "") {
        if(empty($key)) {
            $_SESSION['info'][] = $string;
        } else {
            $_SESSION['info'][$key] = $string;
        }
    }
    function get($key = "") {
        if(empty($key)) {
            return $_SESSION['info'];
        }
        return $_SESSION['info'][$key];
    }
    function clear() {
        unset($_SESSION['info']);
    }
    function display() {
	    foreach(Info::get() as $info) {
	        $display .= $info.'<br/>';
	    }
	     if(!empty($display)) {
	        $out = "<strong>DEBUG INFO</strong><br/>";
	        $out .= "<code>";
	        $out .= $display;
	        $out .= "</code>";
	        echo $out;
        }
    }
    function dump($var) {
        echo "<pre>";
        var_dump($var);
        echo "</pre>";
    }
}
?>